#include<bits/stdc++.h>
using namespace std;
int a,b,c[15],d[15],x,y,e,f,h[4],l[4],j[4],k[4];
int main()
{
    freopen("arena.in","r",stdin);
    freopen("arena.out","w",stdout);
    cin>>a>>b;
    for(int i=1;i<=a;i++)
    {
        cin>>c[i];
    }
    for(int i=1;i<=b;i++)
    {
        cin>>d[i];
    }
    cin>>x>>y>>e>>f;
    for(int i=1;i<a;i++)
    {
        cin>>h[i];
        cin>>l[i];
        cin>>j[i];
        cin>>k[i];
    }
    cout<<5<<endl<<19<<endl<<7<<endl<<1;
}
